package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HmzReturnDetail;
import com.ruoyi.system.service.IHmzReturnDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 归还单子Controller
 * 
 * @author ruoyi
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/system/HmzReturnDetail")
public class HmzReturnDetailController extends BaseController
{
    @Autowired
    private IHmzReturnDetailService hmzReturnDetailService;

    /**
     * 查询归还单子列表
     */
    @PreAuthorize("@ss.hasPermi('system:HmzReturnDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(HmzReturnDetail hmzReturnDetail)
    {
        startPage();
        List<HmzReturnDetail> list = hmzReturnDetailService.selectHmzReturnDetailList(hmzReturnDetail);
        return getDataTable(list);
    }

    /**
     * 导出归还单子列表
     */
    @PreAuthorize("@ss.hasPermi('system:HmzReturnDetail:export')")
    @Log(title = "归还单子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HmzReturnDetail hmzReturnDetail)
    {
        List<HmzReturnDetail> list = hmzReturnDetailService.selectHmzReturnDetailList(hmzReturnDetail);
        ExcelUtil<HmzReturnDetail> util = new ExcelUtil<HmzReturnDetail>(HmzReturnDetail.class);
        util.exportExcel(response, list, "归还单子数据");
    }

    /**
     * 获取归还单子详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:HmzReturnDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hmzReturnDetailService.selectHmzReturnDetailById(id));
    }

    /**
     * 新增归还单子
     */
    @PreAuthorize("@ss.hasPermi('system:HmzReturnDetail:add')")
    @Log(title = "归还单子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HmzReturnDetail hmzReturnDetail)
    {
        return toAjax(hmzReturnDetailService.insertHmzReturnDetail(hmzReturnDetail));
    }

    /**
     * 修改归还单子
     */
    @PreAuthorize("@ss.hasPermi('system:HmzReturnDetail:edit')")
    @Log(title = "归还单子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmzReturnDetail hmzReturnDetail)
    {
        return toAjax(hmzReturnDetailService.updateHmzReturnDetail(hmzReturnDetail));
    }

    /**
     * 删除归还单子
     */
    @PreAuthorize("@ss.hasPermi('system:HmzReturnDetail:remove')")
    @Log(title = "归还单子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hmzReturnDetailService.deleteHmzReturnDetailByIds(ids));
    }
}
